package com.huawei.uikit.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import o.fmz;
import o.fnc.a;

public class HwColumnLinearLayout extends LinearLayout {
    private int ˊ;
    private int ˋ;
    private int ˎ;
    private boolean ˏ;
    private fmz ॱ;
    private float ॱॱ;

    public HwColumnLinearLayout(Context context) {
        this(context, null, 0);
    }

    public HwColumnLinearLayout(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public HwColumnLinearLayout(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.ˏ = false;
        this.ॱ = new fmz(context);
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, a.ॱ);
        this.ˊ = obtainStyledAttributes.getInt(a.ˎ, Integer.MIN_VALUE);
        obtainStyledAttributes.recycle();
    }

    protected void onMeasure(int i, int i2) {
        ˊ();
        if (this.ˊ == Integer.MIN_VALUE) {
            super.onMeasure(i, i2);
            return;
        }
        ˏ(getContext());
        if (this.ˊ == 1) {
            ˎ();
        }
        int size = MeasureSpec.getSize(i);
        super.onMeasure(MeasureSpec.makeMeasureSpec(ॱ(size), MeasureSpec.getMode(i)), i2);
    }

    private void ˏ(Context context) {
        if (this.ˏ) {
            ॱ(getContext());
        } else {
            ˎ(getContext());
        }
    }

    private void ॱ(Context context) {
        this.ॱ.ॱ(this.ˊ);
        this.ॱ.ˊ(context, this.ˋ, this.ˎ, this.ॱॱ);
    }

    private void ˎ(Context context) {
        this.ॱ.ॱ(this.ˊ);
        this.ॱ.ˋ(context);
    }

    private void ˊ() {
        if (this.ˊ == 1) {
            int childCount = getChildCount();
            if (childCount > 1) {
                this.ˊ = 2;
            } else if (childCount == 1) {
                this.ˊ = 1;
            } else {
                this.ˊ = Integer.MIN_VALUE;
            }
        }
    }

    private void ˎ() {
        View childAt = getChildAt(0);
        if (childAt != null) {
            childAt.setMinimumWidth(this.ॱ.ˎ());
        }
    }

    private int ॱ(int i) {
        int ॱ = this.ॱ.ॱ();
        return (ॱ < 0 || ॱ > i) ? i : ॱ;
    }

    public void setColumnType(int i) {
        this.ˊ = i;
        ˎ((ViewGroup) this);
    }

    private void ˎ(ViewGroup viewGroup) {
        int childCount = viewGroup.getChildCount();
        if (childCount == 0) {
            viewGroup.requestLayout();
            viewGroup.invalidate();
            return;
        }
        for (int i = 0; i < childCount; i++) {
            View childAt = viewGroup.getChildAt(i);
            if (childAt instanceof ViewGroup) {
                ˎ((ViewGroup) childAt);
            } else if (childAt != null) {
                childAt.requestLayout();
                childAt.invalidate();
            }
        }
    }
}
